package cloud.take.off.controller.product;

import cloud.take.off.module.common.ListResult;
import cloud.take.off.module.common.R;
import cloud.take.off.module.product.dto.ProductInfoDTO;
import cloud.take.off.module.product.vo.ProductInfoVO;
import cloud.take.off.mybatis.support.Query;
import cloud.take.off.service.IProductInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: TODO
 * @Author: Take-off
 * @Date: 2024/10/9 2:16 PM
 * @Param
 * @return
 * @Version: 1.0
 **/
@RestController
@RequestMapping("/product-info")
@AllArgsConstructor
@Api(value = "商品信息", tags = "库存商品-商品信息")
public class ProductInfoController {

    public final IProductInfoService productInfoService;

    @PostMapping("/submit")
    @ApiOperation(value = "新增或修改", notes = "新增或修改")
    public R submit(@RequestBody ProductInfoVO productInfoVO){
        boolean result = productInfoService.submit(productInfoVO);
        return R.status(result);
    }

    @PostMapping("/detail")
    @ApiOperation(value = "详情", notes = "详情")
    public R<ProductInfoVO> detail(@RequestBody ProductInfoDTO dto){
        ProductInfoVO infoVO = productInfoService.detail(dto);
        return R.data(infoVO);
    }

    @PostMapping("/remove")
    @ApiOperation(value = "删除", notes = "传入 ids")
    public R remove(@RequestBody ProductInfoDTO dto) {
        boolean result = productInfoService.deleteLogic(dto.getIds());
        return R.status(result);
    }
    @PostMapping("/list")
    @ApiOperation(value = "分页", notes = "传入 query")
    public ListResult<ProductInfoVO> list(@RequestBody Query query) {
        return productInfoService.list(query);
    }

}
